-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(papyrus_storage): add append_events function that writes the events of a block to storage #2900
base: alonl/event_storage_split
Are you sure you want to change the base?
Conversation
Benchmark movements: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 3 files at r3, all commit messages.
Reviewable status: 3 of 7 files reviewed, 4 unresolved discussions (waiting on @AlonLStarkWare)
crates/papyrus_storage/src/body/events.rs
line 377 at r3 (raw file):
DbCursor<'txn, RO, TransactionIndex, VersionZeroWrapper<TransactionMetadata>, SimpleTable>; /// interface for updating the events in the storage.
capitalization
crates/papyrus_storage/src/body/events.rs
line 382 at r3 (raw file):
Self: Sized, { /// Appends the events of an entire block to the storage.
Copy this comment:
sequencer/crates/papyrus_storage/src/class.rs
Line 118 in 34c98a0
// To enforce that no commit happen after a failure, we consume and return Self on success. |
crates/papyrus_storage/src/body/events.rs
line 386 at r3 (raw file):
self, block_number: BlockNumber, block_events: Vec<Vec<Event>>,
Receive this by reference and as an array slice and not a vec: &[&[Event]]
In general if you don't need to consume the value it's better to pass it by reference (as long as you don't clone it anywhere)
Also, in general it's better to receive &[T] instead of &Vec as the former can handle the latter yet also handle different stuff like arrays (You'll find that useful in tests for example)
crates/papyrus_storage/src/body/events.rs
line 425 at r3 (raw file):
for (index, transaction_events) in block_events.iter().enumerate() { let transaction_index = TransactionIndex(block_number, TransactionOffsetInBlock(index)); let event_offset = file_handlers.append_events(&transaction_events.clone());
Why clone?
ab03de4
to
63f915f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 7 files reviewed, 4 unresolved discussions (waiting on @ShahakShama)
crates/papyrus_storage/src/body/events.rs
line 377 at r3 (raw file):
Previously, ShahakShama wrote…
capitalization
Done.
crates/papyrus_storage/src/body/events.rs
line 382 at r3 (raw file):
Previously, ShahakShama wrote…
Copy this comment:
sequencer/crates/papyrus_storage/src/class.rs
Line 118 in 34c98a0
// To enforce that no commit happen after a failure, we consume and return Self on success.
Done.
crates/papyrus_storage/src/body/events.rs
line 386 at r3 (raw file):
Previously, ShahakShama wrote…
Receive this by reference and as an array slice and not a vec: &[&[Event]]
In general if you don't need to consume the value it's better to pass it by reference (as long as you don't clone it anywhere)
Also, in general it's better to receive &[T] instead of &Vec as the former can handle the latter yet also handle different stuff like arrays (You'll find that useful in tests for example)
Done.
crates/papyrus_storage/src/body/events.rs
line 425 at r3 (raw file):
Previously, ShahakShama wrote…
Why clone?
Done
63f915f
to
298f1b1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 5 files at r4, 2 of 5 files at r8, 4 of 4 files at r9, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @AlonLStarkWare and @noamsp-starkware)
crates/papyrus_storage/src/body/mod.rs
line 89 at r9 (raw file):
CommonPrefix, >; // TODO: remove the dead code attribute.
Name this TODO on you
crates/papyrus_storage/src/body/events.rs
line 415 at r9 (raw file):
let transaction_index = TransactionIndex(block_number, TransactionOffsetInBlock(index)); let event_offset = self.file_handlers.append_events(transaction_events);
event -> events
Is this called offset regularly? maybe file_offset for clarity
crates/papyrus_storage/src/body/events.rs
line 417 at r9 (raw file):
let event_offset = self.file_handlers.append_events(transaction_events); events_table.append(&self.txn, &transaction_index, &event_offset)?; for event in transaction_events {
It looks like in main we gather all the contract addresses of all the events of a single tx and then write them all together. Could you do the same here?
crates/papyrus_storage/src/lib.rs
line 725 at r9 (raw file):
// Appends an event to the corresponding file and returns its location. fn append_events(&self, events: &[Event]) -> LocationInFile { self.clone().event.append(&events.to_vec())
If you need to do that, then it's better the type will be Vec
So the outer type should be &[&Vec]
71dc6a1
to
4c98372
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 4 of 7 files reviewed, 4 unresolved discussions (waiting on @noamsp-starkware and @ShahakShama)
crates/papyrus_storage/src/lib.rs
line 725 at r9 (raw file):
Previously, ShahakShama wrote…
If you need to do that, then it's better the type will be Vec
So the outer type should be &[&Vec]
Done.
crates/papyrus_storage/src/body/events.rs
line 415 at r9 (raw file):
Previously, ShahakShama wrote…
event -> events
Is this called offset regularly? maybe file_offset for clarity
It is only called once. I can change the name to event_location to match the transaction case (where the return value of file_handlers.append_transactions is named tx_location)
crates/papyrus_storage/src/body/mod.rs
line 89 at r9 (raw file):
Previously, ShahakShama wrote…
Name this TODO on you
It's already removed in a later PR but sure
4c98372
to
6429ca0
Compare
No description provided.